using System;

namespace ELS.Configuration
{
	#region ListChangedEventArgs
	/// <summary>
	/// Provides data for the <see cref="ELS.Configuration.HashList.ListChanged"/> event.
	/// </summary>
	public class ListChangedEventArgs : EventArgs
	{
		#region variables
		private int _oldIndex = -1;
		private int _newIndex = -1;
		private ListChangedType _listChangedType;
		#endregion variables

		#region constructors
		/// <summary>
		/// Initializes a new instance of the ListChangedEventArgs class, when given the way the list changed and the new size of the collection.
		/// </summary>
		/// <param name="listChangedType">One of the <see cref="ELS.Configuration.ListChangedType"/> values.</param>
		/// <param name="newIndex">The new index of the item in the list.</param>
		public ListChangedEventArgs(ListChangedType listChangedType, int newIndex ):this( listChangedType, newIndex, -1)
		{
		}

		/// <summary>
		/// Initializes a new instance of the ListChangedEventArgs class, when given the way the list changed and the new size of the collection.
		/// </summary>
		/// <param name="listChangedType">One of the <see cref="ELS.Configuration.ListChangedType"/> values.</param>
		/// <param name="newIndex">The new index of the item in the list.</param>
		/// <param name="oldIndex">The old index of the item in the list.</param>
		public ListChangedEventArgs(ListChangedType listChangedType, int newIndex, int oldIndex )
		{
			_listChangedType = listChangedType;
			_newIndex = newIndex;
			_oldIndex = oldIndex;
		}
		#endregion constructors

		#region public properties
		/// <summary>
		/// Gets the new index of the item in the list.
		/// </summary>
		public int NewIndex
		{
			get { return _newIndex; }
		}

		/// <summary>
		/// Gets the old index of the item in the list.
		/// </summary>
		public int OldIndex
		{
			get { return _oldIndex; }
		}

		/// <summary>
		/// Gets the way that the list changed.
		/// </summary>
		public ListChangedType ListChangedType
		{
			get { return _listChangedType; }
		}
		#endregion public properties
	}
	#endregion ListChangedEventArgs

	#region ListChangedEventHandler
	/// <summary>
	/// Represents the method that will handle the ListChanged event of the <see cref="ELS.Configuration.HashList"/> class.
	/// </summary>
	public delegate void ListChangedEventHandler ( object sender, ListChangedEventArgs e);
	#endregion ListChangedEventHandler
}
